package com.sxf.domain.blog;

import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.sxf.domain.UserMeta;

/**
 * 评论(与数据对应)
 * 
 * @author SXF
 * 
 */
@Entity
@Table(name = "wp_comments")
@DynamicInsert
@DynamicUpdate
public class Comment implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Column(name = "post_id", nullable = false)
	private Long postId;

	@Column(name = "author", nullable = false)
	private String author;

	@Column(name = "author_email", length = 100, nullable = false)
	private String authorEmail;

	@Column(name = "author_url", length = 200, nullable = false)
	private String authorUrl;

	@Column(name = "author_ip", length = 100, nullable = false)
	private String authorIp;

	@Column(name = "date", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date date;// 评论日期

	@Column(name = "date_gmt", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date dateGmt;

	/**
	 * 评分系统插件(对评论评分)
	 */
	@Column(name = "karma", nullable = false)
	private Integer karma;

	@Column(name = "approved", length = 20, nullable = false)
	private String approved;// 0,审核中;1,审核通过;spam,垃圾评论;trash,回收站

	/**
	 * 代理
	 */
	@Column(name = "agent", nullable = false)
	private String agent;

	@Column(name = "type", length = 20, nullable = false)
	private String type;

	@Column(name = "parent", nullable = false)
	private Long parent;

	@Column(name = "user_id", nullable = false)
	private Long userId;

	@Lob
	@Column(name = "content", nullable = false, columnDefinition = "clob")
	private String content;

	@Transient
	@OneToMany(targetEntity = CommentMeta.class, mappedBy = "commentId")
	private Set<CommentMeta> commentMeta = new LinkedHashSet<CommentMeta>();

	private static final long serialVersionUID = 1L;

	public Comment() {

	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getPostId() {
		return postId;
	}

	public void setPostId(Long postId) {
		this.postId = postId;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getAuthorEmail() {
		return authorEmail;
	}

	public void setAuthorEmail(String authorEmail) {
		this.authorEmail = authorEmail;
	}

	public String getAuthorUrl() {
		return authorUrl;
	}

	public void setAuthorUrl(String authorUrl) {
		this.authorUrl = authorUrl;
	}

	public String getAuthorIp() {
		return authorIp;
	}

	public void setAuthorIp(String authorIp) {
		this.authorIp = authorIp;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Date getDateGmt() {
		return dateGmt;
	}

	public void setDateGmt(Date dateGmt) {
		this.dateGmt = dateGmt;
	}

	public Integer getKarma() {
		return karma;
	}

	public void setKarma(Integer karma) {
		this.karma = karma;
	}

	public String getApproved() {
		return approved;
	}

	public void setApproved(String approved) {
		this.approved = approved;
	}

	public String getAgent() {
		return agent;
	}

	public void setAgent(String agent) {
		this.agent = agent;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Long getParent() {
		return parent;
	}

	public void setParent(Long parent) {
		this.parent = parent;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Set<CommentMeta> getCommentMeta() {
		return commentMeta;
	}

	public void setCommentMeta(Set<CommentMeta> commentMeta) {
		this.commentMeta = commentMeta;
	}

}
